﻿using FluentAssertions;
using FluentAssertions.Assertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using ServiceProxy;

namespace CalculatorThree.UnitTests
{
    [TestClass]
    public class CalculatorUnitIntegrationTests
    {
        [TestMethod]
        public void Add_WhenInnerProxyOfClientProxyIsMocked_ShouldInnerProxyBeCalledWithCorrectArguments()
        {
            //Arrange
            var innerProxy = new Mock<ICalculatorChannel>();
            innerProxy.Setup(i => i.add(It.IsAny<float>(), It.IsAny<float>())).Returns(42);

            var clientProxy = new ClientProxy<ICalculatorChannel>(innerProxy.Object);

            var calculator = new Calculator(clientProxy);

            //Act
            float response = calculator.Add(30, 12);

            //Assert
            innerProxy.Verify(c => c.add(30, 12), Times.Once());
            response.Should().BeApproximately(42, 0);
        }
    }
}